
import http_request from "../../../Common/http_request";
import UserService from "../../services/userService";
import { mgrs, sers } from "../../system/OverallSystem ";
import PageBase from "./pageBase";

const { ccclass, property } = cc._decorator;

@ccclass
export default class YInsi extends PageBase {


    @property(cc.RichText)
    tishiLabel:cc.RichText = null

    private url = "https://changshazhise01-1254961065.cos.ap-guangzhou.myqcloud.com/zhise/oppo/test_email.json"
    onLoad() {

    }

    start() {
        http_request.getInstance().get(this.url, null, this.show.bind(this));
    }

    show(data){
        let taht = this
        const jsonData: object = data;
         
        console.log(jsonData)
        let str = ''
        for (const key in jsonData) {
            if (Object.prototype.hasOwnProperty.call(jsonData, key)) {
                const item = jsonData[key];
                let s = ''
                if(item.style && item.style.bold){
                    if(item.test instanceof Array){
                        let x = ''
                        for (const iterator of item.test) {
                            x+=iterator
                        }
                        s = `<b>${x}</b>`
                    }else{
                        s = `<b>${item.text}</b>`

                    }
                }else{
                    if(item.test instanceof Array){
                        let x = ''
                        for (const iterator of item.test) {
                            x+=iterator
                        }
                        s = `${x}`
                    }else{
                        s = `${item.text}`
                    }
                }
                str += s
            }
        }
      
        str = str.replace(/company/gi,UserService.vivoSDKdata.zs_company)
        str = str.replace(/email/gi,'email:'+UserService.vivoSDKdata.zs_postbox)
        // str = str.replace(/company/gi,UserService.vivoSDKdata.zs_company)

        taht.tishiLabel.string = str
        taht.scheduleOnce(()=>{
            taht.tishiLabel.node.parent.height = taht.tishiLabel.node.height
        })
    }

    // update (dt) {}
}
